package com.powernode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.powernode.utils.AuthUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.mapper.MemberMapper;
import com.powernode.domain.Member;
import com.powernode.service.MemberService;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    protected MemberMapper memberMapper;

    /**
     * 根据openId修改会员信息
     *
     * @param member
     * @return
     */
    @Override
    public Boolean modifyMemberInfoByOpenId(Member member) {
        String openId = AuthUtils.getMemberOpenId();
        //更新会员的头像和昵称
        return memberMapper.update(member, new LambdaQueryWrapper<Member>()
                .eq(Member::getOpenId, openId)) > 0;
    }
}
